Skip to content

Remote control for Teams: the organization stack runs its own relay, and hosted Team chats reconnect and name the typist - #2987

Merged
AbirAbbas merged 18 commits into
devfrom
w26/rc-teams-relay
Nov 26, 2026
Merged

AbirAbbas merged 18 commits into
devfrom
w26/rc-teams-relay

Conversation

@AbirAbbas

Copy link
Copy Markdown
Collaborator

Remote control (#2965) was built before Teams landed on dev. This change makes it work for an organization's own stack and for hosted Team chats. Everything new is opt-in, and personal use is unchanged.

The organization stack runs its own relay

  • deploy/org/compose.yaml gains a relay service, with a healthcheck and a volume. It runs codeaf relay --storage off on 127.0.0.1:8788, bound the way the server's port is.
    • --storage off is a new relay flag. The relay still keeps the device list that pairing, presence and remote control need, but refuses chat uploads.
    • Storage stays off because the organization's server already keeps everyone's chats.
  • When CODEAF_ORG_RELAY_URL is set, the organization server advertises it to signed-in people as relay_url. Running codeaf pair --org <org> then pairs a member's computers through that relay.
    • An explicit --via or CODEAF_SYNC_URL still wins, so bringing your own relay keeps working.
    • People outside an organization keep the public relay exactly as before.
  • deploy/org/railway/make-template.sh adds the relay as a seventh service with its own domain. A relay's requests are signed with their path, so it can't share the server's domain.
  • deploy/org/smoke.sh gains relay sections. The new TestOrgRelayE2E has two computers pair through an organization relay running with storage off, and one opens the other's chat live.

Remote control for hosted Team chats

  • The server names the typist. In a shared hosted chat, "typing from " used to come from the member's own hello, so a member could appear as someone else. The server now sets it from the person it authenticated, and a bot reads as "'s bot". It also drops any client-supplied remote stamp.
  • A dropped codeaf chat --org window reconnects. It used to end for good when its link dropped. It now comes back as a returning window, and ends at once with the server's own words on 401, 403 or 404. --once is never retried.
    • This adds an opt-in EndsOn hook in internal/remote/redial.go; the ssh and relay doors behave as before.
  • Guard tests pin where the personal and organization guest laws may differ.

Manual

  • A new page, organization-relay.md, covers "self-hosted team relay", "use my organization's relay" and "use my own relay instead".
  • remote-control.md and organization-hosted-sessions.md cover remote control inside an organization and a hosted chat that reconnects.
  • Manual probes were added.

Checked locally

  • make test-quick passed on the merged tree (build, vet including Windows, fmt, the packed manual, change entry, the manual law and the laws).
  • The new tests failed before their fixes and pass after. TestOrgRelayE2E passed in 22 s, and the personal remote-control e2e passed in 71 s.
  • The full touched-package legs did not finish on the IO-starved laptop, so CI's touched-packages run is the arbiter here.
  • TestANewChatsFirstTurnIsOnTheOtherComputersHomeWhileItRuns asserts a time limit: the row must arrive within 8 s. Under heavy load it fails on dev too (5 of 6 passed at base and 4 of 6 at head, interleaved on one box), so it is a load-sensitive test, not a regression.

Not run here

  • Docker isn't usable on the laptop that built this, so docker compose up and ./smoke.sh still need a run where Docker works. Its relay sections did run against the real role scripts, without containers.
  • A real sessionhost needs root or docker, so the hosted-chat cases ran in-process.

Follow-ups (not in this change)

  • Storage-request row: Settings → Devices offers "Open request on GitHub" for any relay that reports storage off, including an organization's own relay, where the request means nothing. The manual says so in words.
  • No move to the org relay: a computer already paired on the public relay can't be moved to the organization's relay with pair --org.
  • Desktop org window: it doesn't reconnect yet and shows no keyboard line.
  • Pinned release: the pinned fetch release has neither relay --storage nor relay_url, so the stack keeps building from source until a release carries both.

🤖 Generated with Claude Code

AbirAbbas and others added 18 commits November 26, 2026 10:12
A relay run with --store answers every identity's directory and takes its
chats' sealed content. An organization that already keeps its people's hosted
chats has no use for a second copy, and a relay that says nothing about storage
makes every client try an upload, be refused and try again.

--storage off serves the directory as before, answers GET /v1/store/stats with
"storage": "off" (the word the hosted relay uses, so clients keep their chats
local and stop asking), refuses POST /v1/store/frames with 403 storage_off and
accepts the handoff a rotation sends. The default is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An organization that runs its own relay needs a way to tell its members where
it is without every one of them setting an environment variable. The host
config takes relay_url, the server checks it at start (a web address, http or
https, with no sign-in, query or fragment in it, and an error that never echoes
the address back), and GET /v1/org carries it as "relay" for a signed-in person
only. A stranger is told nothing; /v1/about stays as public as it was; a token
rotation keeps the row. A client decides for itself whether it will use the
address (see the pair --org change).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`codeaf pair --org https://org.example.com [--code]` asks the organization
server, with the sign-in the person already has, which relay it runs, and then
pairs exactly as `--via <that address>` does, so the relay is remembered and
handed to the computer being paired. A computer that never says --org asks no
organization anything, an explicit CODEAF_SYNC_URL (a relay or `off`) still
wins, and --org together with --via is refused in a sentence. An organization
that names no relay, a sign-in it does not know, a server that is not there, a
non-web address, or an http relay named over https each end the pairing with a
plain sentence and nothing is paired through it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Every new person-facing "relay" string names the server (the pairing sentences
and flag help, relay_url, the relay tag of GET /v1/org), and the relay's own
help page is now about its storage switch too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, not by the member's own hello

The chat's other windows read the name of the window that holds the keyboard ("typing from mia"). On the guest wire that name
came straight from the member's hello, so a member could make their window read as the owner, as another member, or as
"another window", and could stamp the hello as a remote viewer of someone's own computers, which changes the keyboard,
resend and guest rules the engine applies to it.

The guest wire now writes the surface itself: the person as this server knows them, or "<creator>'s bot" for a bot, and drops
any remote stamp. Two table laws pin where the personal guest law and the organization's guest law may differ, so a method
added to the wire cannot drift apart on one side without a line saying why.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Roaming gains an optional EndsOn hook. When a redial is answered with an error the hook calls final, the client ends at once with the
far end's own words instead of spending the whole redial window saying it is reconnecting. With no hook the schedule is
exactly what it was, so the ssh and relay doors keep their behaviour.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… drops

A terminal opened on a hosted chat ended for good when the link to the organization's server broke (a laptop that slept, a
network that changed, a server that restarted), although the chat goes on running there. The window now roams: it redials as a
returning window, so it does not take the keyboard from whoever holds it, and it ends at once with the server's own words when
the server says the sign-in or the chat is gone (401, 403, 404). A one-shot --once run is never retried.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A `relay` service runs `codeaf relay` from the same image (role `relay`), so
the computers of an organization's members can pair, see each other and open
each other's chats live without the public relay. It keeps each member's
device list on a volume and no chat content (the organization already keeps
the hosted chats), listens on 127.0.0.1:8788 like the organization server's
8787 (CODEAF_RELAY_BIND and CODEAF_RELAY_PORT change that), and is healthy
when its page for a pairing link answers, which names nobody. A relay asked to
leave chats out on a codeaf that predates the switch stops in words instead of
keeping them. CODEAF_ORG_RELAY_URL becomes the relay_url the organization
server tells its signed-in people. The offline shell tests join the gate that
already runs the other deploy/org ones.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
make-template.sh adds the relay as a seventh image-sourced service in its
relay role, with its own volume and public domain on its own port, Railway's
edge trusted, storage and the connected-computers page off, a /p/health check,
and tells the codeaf service its address (CODEAF_ORG_RELAY_URL) once the
domain exists. The offline tests pin each of those calls and the new counts of
volumes and edits. Railway itself is not touched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…econnects

Two pages say what a person with an organization can expect: which chats remote control reaches (their own computers' chats, not
the organization's hosted ones, which have their own access), who reads as typing in a shared chat, and what the terminal does
when its link to the server breaks (reconnects for up to five minutes, ends at once with the server's words when access went,
never retries a --once run, and that the desktop window does not reconnect yet). Four probes in a person's own words reach them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
New relay and relay-after sections, run in the codeaf container with no
CODEAF_SYNC_URL anywhere: the relay answers its health page and does not list
who is connected, the organization tells a signed-in owner where its relay is
and a stranger nothing, and two throwaway computers pair with `codeaf pair
--org` and `codeaf pair <code> --via`, each lists the other in `codeaf devices`
and names the organization's relay, and the second kept the address it was told.
smoke.sh adds what only the relay's volume shows (it started with chat storage
off, it holds the device list and no chat content), and after the restart of
every service the two computers still see each other.

Opening a chat live needs a terminal, which the image has none of, so
SMOKE_RELAY_LIVE=1 runs the Go test TestOrgRelayE2E on the host against the
stack's published relay.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s the other's chat live

TestOrgRelayE2E starts the relay the way the organization stack does
(deploy/org/scripts/relay.sh, storage off), points two throwaway homes at it
with no CODEAF_SYNC_URL anywhere, pairs them with the saved relay, and has one
open the other's running chat live and type into it (remote control on, the
rig's scripted model). It then asserts the relay was never asked to keep a chat
and its folder holds the device lists and no chat file. CODEAF_E2E_ORG_RELAY
points it at a relay that is already running instead, which is how smoke.sh
runs it against the compose relay with SMOKE_RELAY_LIVE=1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
deploy/org/README.md gains the operator's walkthrough (the relay service, its
own name and https, CODEAF_ORG_RELAY_URL, the CODEAF_RELAY_* settings, what is
and is not kept, that the relay has no list of people), and docs/organizations.md
and docs/relay.md name the service, the --storage flag and `codeaf pair --org`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…wn relay instead

A new chat page answers the questions an organization's members and operators
ask about the relay the stack now runs: what it is and keeps, `codeaf pair
--org` and what it says when it stops, that --via and CODEAF_SYNC_URL still
win, who can reach it, and how to run one. The pages that said Docker had no
relay and that every relay keeps chats now say what an organization's stack does.

The headings and wording were tuned against the whole probe table: adding six
sections moves every ranking by a few thousandths, and three existing questions
sat on exact ties at the fourth place ("what does Your chat mean on a task",
"set effort to max", "how do I take a chat back from my other computer"). The
page avoids the words those questions turn on rather than the probes changing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…remembers the old stack

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AbirAbbas
AbirAbbas merged commit 4a81769 into dev Nov 26, 2026
8 checks passed
@AbirAbbas
AbirAbbas deleted the w26/rc-teams-relay branch November 26, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant